package com.itic.mall.system.users.useLog.service;

import com.itic.appbase.framework.common.service.CrudService;
import com.itic.mall.system.inter.users.useLog.persistence.dao.UseLogDao;
import com.itic.mall.system.inter.users.useLog.persistence.model.UseLog;
import com.itic.mall.system.inter.users.useLog.persistence.model.UseLogExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;


@Service
@Transactional
public class UseLogService
     extends CrudService<UseLogDao,UseLog,UseLogExample> {
    @Autowired
    private UseLogDao useLogDao;

    public String addUseLog(String userId) {
    	UseLog useLog = new UseLog();
    	useLog.setUserId(userId);
    	String result = this.add(useLog);
    	return result;
    }
    
    public int getUserLateUseCount(String userId,Date date) {
    	Map<String, Object> params = new HashMap<String, Object>();
    	params.put("userId", userId);
    	params.put("date", date);
    	Integer count = this.useLogDao.getUserLateUseCount(params);
    	return count <=0?0:count.intValue();
    }
    
    
}